﻿using System;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using O1;
using O1.Data;
using O1.Data.Traversal;

namespace Tests.O1.Data.Traversal
{
    [TestClass]
    public class EdgeFilterTests
    {
        [TestMethod, TestCategory("Unit Test")]
        public void EdgeFilterIsInterestedByDefault()
        {
            var subject = new EdgeFilter();
            subject.StartEdge(new Edge(11, 1000, 01), EdgeDirections.Inbound).Should().Be(ObservationInterests.Interested);
            subject.StartEdge(new Edge(11, 1000, 01), EdgeDirections.Outbound).Should().Be(ObservationInterests.Interested);
        }

        [TestMethod, TestCategory("Unit Test")]
        public void EdgeFilterIsInterestedInOnlyIncludedEdge()
        {
            var inclusions = new EdgeSet(3);
            inclusions.Add(EdgeDirections.Inbound, 11);
            var subject = new EdgeFilter(inclusions);
            subject.StartEdge(new Edge(11, 1000, 11), EdgeDirections.Inbound).Should().Be(ObservationInterests.Interested);
            subject.StartEdge(new Edge(11, 1000, 11), EdgeDirections.Outbound).Should().Be(ObservationInterests.None);
        }

        [TestMethod, TestCategory("Unit Test")]
        public void EdgeFilterIsInterestedInNonExcludedEdges()
        {
            var exclusions = new EdgeSet(3);
            exclusions.Add(EdgeDirections.Inbound, 11);
            var subject = new EdgeFilter(null, exclusions);
            subject.StartEdge(new Edge(11, 1000, 11), EdgeDirections.Inbound).Should().Be(ObservationInterests.None);
            subject.StartEdge(new Edge(11, 1000, 11), EdgeDirections.Outbound).Should().Be(ObservationInterests.Interested);
        }
    }
}
